Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Tooltip): improve a11y on trigger element #1437

Merged
merged 4 commits into from
Dec 4, 2024

Conversation

akdetrick
Copy link
Collaborator

@akdetrick akdetrick commented Dec 2, 2024

closes NDS-701

Summary

Keyboard-only (and other assistive tech) users are able to navigate to the trigger of the tooltip element and operate it, which is good. However, the trigger element has a role="button". There's no actual button action though; it only exists to create a focus/blur side effect for keyboard users.
This is also an issue because every tooltip trigger is getting added to navigation landmarks, which seems wrong.

Loom video of this issue (🔉 sound on)

Changes

All Tooltip trigger elements should be read as focusable text content by assistive tech. The tooltip itself should be announced "politely" only when the tooltip appears.

  • Remove button ARIA role from the popover trigger. It doesn't actually take an action and acts passively as it's focused, so it should not have a button role.
  • Adds aria-expanded to make it clear that the announced tooltip content is in a modal toolip

The WAI-ARIA working group doesn't endorse any specific tooltip pattern officially, but this interaction pattern as implemented matches the spec for a snackbar in Material Design.

@akdetrick akdetrick marked this pull request as draft December 3, 2024 00:04
@akdetrick akdetrick marked this pull request as ready for review December 3, 2024 04:10
Copy link
Contributor

@graphicsforge graphicsforge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, it's not a button but needs a tabindex

@akdetrick
Copy link
Collaborator Author

ah, it's not a button but needs a tabindex

Exactly - it's a weird solution, but a workable one for something that only happens on focus/blur rather than actual button press

Copy link

github-actions bot commented Dec 4, 2024

📘 Storybook Preview Available 👀

View the Storybook build from this PR in your browser:
https://60620d422ffdf100216415b2-dbtqnrguha.chromatic.com/

(This action will publish a new comment and url if this PR is modified)

@akdetrick akdetrick merged commit c201415 into main Dec 4, 2024
7 checks passed
@akdetrick akdetrick deleted the a11y/NDS-701-tooltip-button-label branch December 4, 2024 22:04
@narmirobot
Copy link

🎉 This PR is included in version 3.69.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants